//----------------------------------------------------------------------------------------
// @Project Includes
#include "includes.h"

//----------------------------------------------------------------------------------------
// @Local Macro Define in the module

//----------------------------------------------------------------------------------------
// @Local Type defines in the module

//----------------------------------------------------------------------------------------
// @Global Variables define in the module

//----------------------------------------------------------------------------------------
// @Prototypes of functions in the module

//----------------------------------------------------------------------------------------
/**
 * @brief  This function control different contactor seperately
 * @param  cnt_id:
*          enable: mos state
 * @return none
 * @note   none
 */
void srv_contactor_ctl(const en_contactor_id_t cnt_id, const uint8_t enable)
{
    switch (cnt_id)
    {
        case CNT_DSG:
					  if (enable)
            {
							  g_stcVar.bdsgMosCtl = true;
            }
            else
            {
							  g_stcVar.bdsgMosCtl = false;
            }
			      break;			
			
        case CNT_CHG:
					  if (enable)
            {
							  g_stcVar.bchgMosCtl = true;
            }
            else
            {
							  g_stcVar.bchgMosCtl = false;
            }
            break;

        case CNT_PCHG:
					  if (enable)
            {
							  g_stcVar.bpchgMosCtl = true;
            }
            else
            {
							  g_stcVar.bpchgMosCtl = false;
            }
            break;
						
        case CNT_PDSG:
					  if (enable)
            {
							  g_stcVar.bpdsgMosCtl = true;
            }
            else
            {
							  g_stcVar.bpdsgMosCtl = false;
            }
            break;						

        case CNT_ALL:
						if(!enable)
						{
								g_stcVar.bchgMosCtl = false;
								g_stcVar.bdsgMosCtl = false;
								g_stcVar.bpchgMosCtl = false;
								g_stcVar.bpdsgMosCtl = false;
						}
						else
						{
								g_stcVar.bchgMosCtl = true;
								g_stcVar.bdsgMosCtl = true;
								g_stcVar.bpchgMosCtl = true;
								g_stcVar.bpdsgMosCtl = true;						
						}
            break;
						
        default:
            break;
    }
}

/**
 * @brief  Get Contactor State
 * @param  cnt_id:
 * @return true: mos is enable
 *         false: mos is disable
 * @note   none
 */
bool_t srv_contactor_getState(const en_contactor_id_t cnt_id)
{
    bool_t rslt = false;

    switch (cnt_id)
    {
        case CNT_CHG:
            rslt = g_stcAfeReg.bstatus1.bit.CHG_FET;
            break;

        case CNT_DSG:
						rslt = g_stcAfeReg.bstatus1.bit.DSG_FET;
						break;

        case CNT_PCHG:
            //rslt = g_stcAfeReg.bstatus1.bit.PCHG_ON;
            break;
        case CNT_PDSG:
            rslt = g_stcAfeReg.bstatus1.bit.PDSG_FET;
            break;	
        case CNT_ALL:
            rslt = g_stcAfeReg.bstatus1.bit.CHG_FET|g_stcAfeReg.bstatus1.bit.DSG_FET;
            break;				
        default:
            rslt = false;
            break;
    }

    return ((bool_t)rslt);
}

// =======================================================================================
// End of file.
// =======================================================================================
